﻿//init the store content
var store = new Ext.data.SimpleStore({
   fields: [
			{name:'id',type:"string"},
      		{name:'name',type:"string"},
			{name:"tel",type:"string"},
			{name:"opt",type:"string"}
     ]
    });

var grid;
//init the gird	
function girdInit()
{
	ContactManager.getContectList(showContactGrid);
}
//delet contact
function delContect(id,name)
{

	if (confirm("您确定要删除操作员["+name+"]吗？")==true)
	{
		ContactManager.del(id,reloadContactGrid);
	}
}
//reload
function reloadContactGrid()
{
	ContactManager.getContectList(reloadContact);
}
//reload ack
function reloadContact(data)
{
	try
	{
		store.loadData(data);
		grid.store.reload();
	}
	catch(e)
	{//有一个不知道怎么解决的问题
		
	}
}
function showContactGrid(data)
{
	Ext.onReady(function(){

    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

    var myData =data;


    // create the data store
    
    store.loadData(myData);

    // create the Grid
   grid = new Ext.grid.GridPanel({
        store: store,
        columns: [
            {id:'姓名',header: "姓名", width:60, sortable: true, dataIndex: 'name'},
            {header:"手机号码",width:80,sortable:true,dataIndex:'tel'},
			{header:"删除",width:30,sortable:false,dataIndex:'opt'}
        ],
        stripeRows: true,
        height:300,
        width:200
    });

    grid.render('grid');

});
}